import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import 'package:app_happy_flutter/code/Feature/Org/page.dart';
import 'package:app_happy_flutter/code/Feature/list/page.dart';
import 'package:app_happy_flutter/code/Feature/grid/page.dart';

import 'action.dart';
import 'state.dart';
import 'TopTabBar.dart';

//tabList是tabbar切换的数据
List tabList = [
  {
    "title":'全部人员',
    "widget":OrganizationPage(),
    "index":0,
  },
  {
    "title":'在场人员',
    "widget":ListPage(),
    "index":1,
  },
  {
    "title":'退场人员',
    "widget":GridPage(),
    "index":2,
  },
];

var personType=0;//人员类型
_renderPersonList(int index,List persons) {

}
  Widget buildView(PersonListState state, Dispatch dispatch,
      ViewService viewService) {
    return MaterialApp(
      theme: ThemeData(
        brightness: Brightness.light,
        primaryColor: Colors.white,
        textTheme: TextTheme(
          title: TextStyle(fontSize: 18.0,),
        ),
      ),
      home: Scaffold(
        backgroundColor: Color(0xFFf5f5f5),
        appBar: AppBar(
          title: Text('劳务人员'),
          leading: GestureDetector(
            onTap: () {
              //顺便提一下，在view.dart里面可以在viewService中找到context，等下告诉你我是怎么找到的
              Navigator.of(viewService.context).pop();
            },
            child: Icon(Icons.arrow_back_ios, color: Colors.grey,),
          ),
          centerTitle: true,
        ),
        body: Column(
          children: <Widget>[
            Container(
              color: Color(0xffffffff),
              height: 50.0,
              //这里将tabBar组件提出去封装了
              child: TopTabBar(tabList: tabList, controller: state.controller),
            ),
            //TabBarView外层加上Expanded，不然会报错，具体报啥忘了，感兴趣的自己去试
            Expanded(
              child: TabBarView(
                controller: state.controller,
                //这里从state中取出controller赋值给TabBarView的controller即可
                children: tabList.map((item) {
                  return Container(
//                      child: Text('页面')
                  );
                }).toList(),
              ),
            )
          ],
        ),
      ),
    );
}
